// File:       poscmd04.c++
// Version:    1.00
// Author:     (c) Miles Sabin, 1997
// Purpose:    put command

// Change log:
//  29/03/97   v. 1.00

#include "poscmds.h"

#include "ostream.h"
#include "streambuf.h"


// Implementation of PutCommand

PutCommand::PutCommand(basic_ostream_char& os, char c)
  : c_(c)
  { execute_template(os); }

PutCommand::~PutCommand()
  {}

ios::iostate PutCommand::execute(basic_ostream_char& os)
  { return (os.rdbuf()->sputc(c_) == basic_ostream_char::traits::eof() ? ios::failbit : ios::goodbit); }


// Implementation of basic_ostream_char

basic_ostream_char& basic_ostream_char::put(char c)
  {
    PutCommand cmd(*this, c);
    return *this;
  }


// Implementation of basic_ostream_char free fns

basic_ostream_char& ends(basic_ostream_char& os)
{
  os.put(basic_ostream_char::traits::eos());
  return os;
}

